# source : https://github.com/archlinux/svntogit-packages/blob/packages/binutils/trunk/PKGBUILD

cd $SRC

[[ ! -d binutils-gdb ]] && ln -s binutils-$surum binutils-gdb
mkdir -p binutils-build

cd binutils-gdb

# Turn off development mode (-Werror, gas run-time checks, date in sonames)
sed -i '/^development=/s/true/false/' bfd/development.sh

# hack! - libiberty configure tests for header files using "$CPP $CPPFLAGS"
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" libiberty/configure

cd $SRC/binutils-build

"$SRC/binutils-gdb/configure" \
--prefix=/usr \
--with-lib-path=/usr/lib:/usr/local/lib \
--enable-cet \
--enable-deterministic-archives \
--enable-gold \
--enable-ld=default \
--enable-lto \
--enable-plugins \
--enable-relro \
--enable-targets=x86_64-pep \
--enable-threads \
--disable-gdb \
--disable-werror \
--with-pic \
--with-system-zlib

make configure-host
make tooldir=/usr

# unset LDFLAGS as testsuite makes assumptions about which ones are active
# ignore failures in gold testsuite...
make -k LDFLAGS="" check || true
